<%@ page import="java.util.HashMap" %>
<%@ page import="utils.string.session.SessionStringUtil" %>
<%@ page import="java.util.Set" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="vo.Equipment" %>
<%@ page import="vo.User" %>
<%--
  Created by IntelliJ IDEA.
  User: Chris
  Date: 2021/5/9
  Time: 15:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>设备管理系统-管理者界面</title>
</head>
<body>
<h2>欢迎${sessionScope.User.user_name}选用设备</h2><br>
<%
    HashMap allEquipments = (HashMap)session.getAttribute(SessionStringUtil.ALL_UNUSED_EQUIPMENTS);
    System.out.println("allEquipment=" + allEquipments);
    User user = (User) request.getSession().getAttribute(SessionStringUtil.USER);
%>
<table border="1">
    <tr bgcolor="pink">
        <td>设备名称</td>
        <td>设备数目</td>
        <td>使用</td>
        <td>维修</td>
        <td>更新</td>
        <td>删除</td>
    </tr>
    <%
        Set set = allEquipments.keySet();
        Iterator ite = set.iterator();
        while(ite.hasNext()){
            int equipmentId = (int)ite.next();
            Equipment equipment = (Equipment) allEquipments.get(equipmentId);
    %>
    <tr bgcolor="yellow">
        <td><%=equipment.getEquip_name()%></td>
        <td><%=equipment.getEquip_num()%></td>
        <td><a href="addUsingConfirm.jsp?equipmentId=<%=equipmentId%>">使用</a></td>
        <td><a href="addFixConfirm.jsp?equipmentId=<%=equipmentId%>">维修</a></td>
        <td><a href="updateEquipmentConfirm.jsp?equipmentId=<%=equipmentId%>">更新</a></td>
        <td><a href="deleteEquipmentConfirm.jsp?equipmentId=<%=equipmentId%>">删除</a></td>
    </tr>
    <%} %>
</table>
<br>
<form name="AddEquipment" action="servlet/AddEquipmentServlet" method="post">
    请您输入设备名称：<input name="addEquipmentName" type="text"><BR>
    请您输入设备数量：<input name="addEquipmentNum" type="number"><BR>
    <input type="submit" value="添加">
</form>
<a href="servlet/AddUsingServlet" methods="get">查看设备所有使用情况</a><br>
<a href="servlet/AddFixServlet" methods="get">查看设备所有维修情况</a>
</body>
</html>
